<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <todo>
        <todo-title slot="todo-title" title="秦老师系列课程"></todo-title>
        <todo-items slot="todo-items" v-for="(item, index) in todoItems" v-bind:item="item" v-bind:index="index"></todo-items>
    </todo>
</div>
</body>

<script src="vue.js"></script>

<script>
    Vue.component('todo', {
        template: '<div>\ \
        <slot name="todo-title"></slot>\ \
        <ul>\ <slot name="todo-items"></slot>\
        </ul>\ </div>'
    });

    Vue.component('todo-title', {
        props: ['title'],
        template: '<div>{{title}}</div>'
    });

    //这里的index,就是数组的下标,使用for循环遍历的时候,可以循环出来!
    Vue.component('todo-items', { props: ['item', 'index'], template: '<li>{{index + 1}}. {{item}}</li>'
    });


    new Vue({
        el: '#app', data: {
            todoItems: ['狂神说Java', '狂神说运维', '狂神说前端']
        }
    })
</script>
</html>